//
//  UIScreen+Frame.m
//  高仿暴走斗图
//
//  Created by huangsongyao on 16/3/7.
//  Copyright © 2016年 huangsongyao. All rights reserved.
//

#import "UIScreen+Frame.h"

@implementation UIScreen (Frame)

#pragma mark - Device Size

+ (CGSize)size
{
    return [[UIScreen mainScreen] bounds].size;
}

+ (CGFloat)width
{
    return [[UIScreen mainScreen] bounds].size.width;
}

+ (CGFloat)height
{
    return [[UIScreen mainScreen] bounds].size.height;
}

+ (CGRect)bounds
{
    return [[UIScreen mainScreen] bounds];
}

#pragma mark - Orientation

+ (CGSize)orientationSize
{
    CGFloat systemVersion = [[[UIDevice currentDevice] systemVersion] doubleValue];
    BOOL isLand = UIInterfaceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation);//是否是竖屏
    
    CGSize size = (systemVersion>8.0 && isLand) ? SizeSWAP([UIScreen size]) : [UIScreen size];//如果是横屏并且系统为8.0以后的，交换高度和宽度
    return size;
}

+ (CGFloat)orientationWidth
{
    return [UIScreen orientationSize].width;
}

+ (CGFloat)orientationHeight
{
    return [UIScreen orientationSize].height;
}

+ (CGSize)retinaSize
{
    CGSize size = [[UIScreen mainScreen] bounds].size;
    CGFloat scale = [[UIScreen mainScreen] scale];
    return CGSizeMake(size.width * scale, size.height * scale);
}


/**
 *  交换高度与宽度
 */
static inline CGSize SizeSWAP(CGSize size) {
    
    return CGSizeMake(size.height, size.width);
}


#pragma mark - Get KeyWindows

+ (UIWindow *)getKeyWindows {
    
    return [[UIApplication sharedApplication] keyWindow];
}


+ (NSString *)getMainBundleForPathForResource:(NSString *)resource ofType:(NSString *)type {
    
    return [[NSBundle mainBundle] pathForResource:resource ofType:type];
}


+ (CGFloat)getStatusBarHeight {
    
    return [[UIApplication sharedApplication] statusBarFrame].size.height;
}

@end
